package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;


@Data
@Entity
@Table(name = "SELLING_EQUITY_LOG")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SellingEquityLog {

	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SELLING_EQUITY_LOG_SEQ")
	@SequenceGenerator(name = "SELLING_EQUITY_LOG_SEQ", allocationSize = 1, sequenceName = "SELLING_EQUITY_LOG_SEQ")
	private Long id;// 主键
	@Column(name = "PRDCONT_ID")
	private String prdContId;// 节目id
	@Column(name = "CONTENT_ID")
	private String contentId;// 内容id
	@Column(name = "MMS_ID")
	private String mmsId;// 媒资id
	private String name;// 内容名称
	@Column(name = "EQUITY_ID")
	private String equityId;// 权益节点id
	@Column(name = "OPT_TYPE")
	private String optType;// 0为删除，1为添加
	@Column(name = "IS_SAL")
	private String isSal; // 0为计费配置，1为促销配置
	private String operator;// 操作人
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "OPERATOR_TIME")
	private Date operateTime;// 操作时间

	public static void putTimeAndUser(SellingEquityLog sellingEquityLog) {
		if (sellingEquityLog.operateTime == null) {
			sellingEquityLog.setOperateTime(new Date());
		}
		sellingEquityLog.setOperator(CurrentUser.currUserName());
	}


}
